package com.powernode.springmvc.controller;

import com.powernode.springmvc.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(path = "/api")
public class UserController {
    @RequestMapping(path = "/user", method = RequestMethod.GET)
    public String getAll() {
        System.out.println("getAll,查询用户所有信息");
        return "ok";
    }

    @RequestMapping(path = "/user/{id}", method = RequestMethod.GET)
    public String getUserById(@PathVariable("id") Integer id) {
        System.out.println("getUserById,查询id:" + id + "的用户信息");
        return "ok";
    }

    @RequestMapping(path = "/user", method = RequestMethod.POST)
    public String addUser(User user) {
        System.out.println("addUser:" + user);
        return "ok";
    }

    @RequestMapping(path = "/user", method = RequestMethod.PUT)
    public String editUser(User user) {
        System.out.println("editUser:" + user);
        return "ok";
    }
}
